<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/6 12:21
 */

namespace module\ai\library\channel\platform;

use module\ai\library\channel\abstract\Platform;
use mof\Model;

class TencentPlatform extends Platform
{
    protected string $regUrl = 'https://cloud.tencent.com/login?s_url=https%3A%2F%2Fconsole.cloud.tencent.com%2Fhunyuan';

    public static function getName(): string
    {
        return '腾讯混元';
    }

    public static function getFlag(): string
    {
        return 'tencent';
    }

    public static function models(): array
    {
        return [
            'hunyuan-lite'         => 'hunyuan-lite(免费)',
            'hunyuan-turbo'        => 'hunyuan-turbo',
            'hunyuan-standard'     => 'hunyuan-standard',
            'hunyuan-pro'          => 'hunyuan-pro',
            'hunyuan-role'         => 'hunyuan-role',
            'hunyuan-code'         => 'hunyuan-code',
            'hunyuan-functioncall' => 'hunyuan-functioncall',
            'hunyuan-vision'       => 'hunyuan-vision',
        ];
    }


    public function getConfigForm(Model $model = null): array
    {
        return [
            ...parent::getConfigForm($model),
            [
                "label" => "temperature",
                "prop"  => "config.temperature",
                "value" => $model['config']['temperature'] ?? '',
                "intro" => "影响输出文本的多样性。取值越大，生成文本的多样性越强。取值区间为 [0.0, 1.0]",
                "tip"   => "模型已有默认参数，不传值时使用各模型推荐值，不推荐用户修改。"
            ],
            [
                "label" => "top_p",
                "prop"  => "config.top_p",
                "value" => $model['config']['top_p'] ?? '',
                "intro" => "影响模型输出多样性。较高的数值会使输出更加多样化和不可预测，而较低的数值会使其更加集中和确定。取值区间为 [0.0, 2.0]。",
                "tip"   => "模型已有默认参数，不传值时使用各模型推荐值，不推荐用户修改。"
            ],
        ];
    }

    public function getKeyColumns(): array
    {
        return [
            'api_key' => [
                'label'  => 'API KEY',
                'secret' => true,
                'intro'  => '请使用OpenAI SDK方式接入',
            ],
        ];
    }
}